namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmYtEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblLoai_Yt;
        private LabelControl lblLoai_Yt0;
        private LabelControl lblMa_Yt;
        private LabelControl lblTen_Yt;
        private LabelControl lblTen_Yt_E;
        private LabelControl lblTk_Cp;
        private LabelControl lblTk_Yt;
        private TextOption txtLoai_Yt;
        private TextControl txtMa_Yt;
        private TextControl txtTen_Yt;
        private TextControl txtTen_Yt_E;
        private TextControl txtTk_Cp;
        private TextControl txtTk_Yt;

        public FormDmYtEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormDmYtEditor));
            this.txtMa_Yt = new TextControl();
            this.lblMa_Yt = new LabelControl();
            this.txtTen_Yt = new TextControl();
            this.lblTen_Yt = new LabelControl();
            this.txtTen_Yt_E = new TextControl();
            this.lblTen_Yt_E = new LabelControl();
            this.lblLoai_Yt = new LabelControl();
            this.txtLoai_Yt = new TextOption();
            this.lblLoai_Yt0 = new LabelControl();
            this.txtTk_Cp = new TextControl();
            this.txtTk_Yt = new TextControl();
            this.lblTk_Cp = new LabelControl();
            this.lblTk_Yt = new LabelControl();
            base.SuspendLayout();
            base.txtMa_Loai3.FirstFilter = "Type = 'SP3'";
            base.txtMa_Loai3.Location = new Point(0x17d, 160);
            base.txtMa_Loai3.Size = new Size(0x7f, 20);
            base.txtMa_Loai3.TabIndex = 9;
            base.txtMa_Loai2.FirstFilter = "Type = 'SP2'";
            base.txtMa_Loai2.Location = new Point(0xfc, 160);
            base.txtMa_Loai2.Size = new Size(0x7f, 20);
            base.txtMa_Loai2.TabIndex = 8;
            base.txtMa_Loai1.FirstFilter = "Type = 'SP1'";
            base.txtMa_Loai1.Location = new Point(0x7b, 160);
            base.txtMa_Loai1.Size = new Size(0x7f, 20);
            base.txtMa_Loai1.TabIndex = 7;
            base.lblPhan_Loai.Location = new Point(12, 0xa3);
            this.txtMa_Yt.CharacterCasing = CharacterCasing.Upper;
            this.txtMa_Yt.CheckTextSearched = false;
            this.txtMa_Yt.DisabledForeColor = Color.Empty;
            this.txtMa_Yt.Font = new Font("Arial", 8.25f);
            this.txtMa_Yt.Location = new Point(0x7b, 0x1c);
            this.txtMa_Yt.MaxLength = 0x20;
            this.txtMa_Yt.Name = "txtMa_Yt";
            this.txtMa_Yt.OldValue = null;
            this.txtMa_Yt.Size = new Size(0x7f, 20);
            this.txtMa_Yt.TabIndex = 0;
            this.txtMa_Yt.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtMa_Yt.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtMa_Yt.Value = null;//manager.GetObject("txtMa_Yt.Value");
            this.lblMa_Yt.AutoSize = true;
            this.lblMa_Yt.Font = new Font("Arial", 8.25f);
            this.lblMa_Yt.Location = new Point(12, 0x1f);
            this.lblMa_Yt.Name = "lblMa_Yt";
            this.lblMa_Yt.Size = new Size(0x36, 14);
            this.lblMa_Yt.TabIndex = 4;
            this.lblMa_Yt.Text = "Mã yếu tố";
            this.txtTen_Yt.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Yt.CheckTextSearched = false;
            this.txtTen_Yt.DisabledForeColor = Color.Empty;
            this.txtTen_Yt.Font = new Font("Arial", 8.25f);
            this.txtTen_Yt.Location = new Point(0x7b, 50);
            this.txtTen_Yt.MaxLength = 128;
            this.txtTen_Yt.Name = "txtTen_Yt";
            this.txtTen_Yt.OldValue = null;
            this.txtTen_Yt.Size = new Size(0x181, 20);
            this.txtTen_Yt.TabIndex = 1;
            this.txtTen_Yt.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Yt.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_Yt.Value = null;//manager.GetObject("txtTen_Yt.Value");
            this.lblTen_Yt.AutoSize = true;
            this.lblTen_Yt.Font = new Font("Arial", 8.25f);
            this.lblTen_Yt.Location = new Point(12, 0x35);
            this.lblTen_Yt.Name = "lblTen_Yt";
            this.lblTen_Yt.Size = new Size(0x3a, 14);
            this.lblTen_Yt.TabIndex = 4;
            this.lblTen_Yt.Text = "Tên yếu tố";
            this.txtTen_Yt_E.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Yt_E.CheckTextSearched = false;
            this.txtTen_Yt_E.DisabledForeColor = Color.Empty;
            this.txtTen_Yt_E.Font = new Font("Arial", 8.25f);
            this.txtTen_Yt_E.Location = new Point(0x7b, 0x48);
            this.txtTen_Yt_E.MaxLength = 128;
            this.txtTen_Yt_E.Name = "txtTen_Yt_E";
            this.txtTen_Yt_E.OldValue = null;
            this.txtTen_Yt_E.Size = new Size(0x181, 20);
            this.txtTen_Yt_E.TabIndex = 2;
            this.txtTen_Yt_E.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Yt_E.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_Yt_E.Value = null;//manager.GetObject("txtTen_Yt_E.Value");
            this.lblTen_Yt_E.AutoSize = true;
            this.lblTen_Yt_E.Font = new Font("Arial", 8.25f);
            this.lblTen_Yt_E.Location = new Point(12, 0x4b);
            this.lblTen_Yt_E.Name = "lblTen_Yt_E";
            this.lblTen_Yt_E.Size = new Size(0x4a, 14);
            this.lblTen_Yt_E.TabIndex = 4;
            this.lblTen_Yt_E.Text = "Tên tiếng Anh";
            this.lblLoai_Yt.AutoSize = true;
            this.lblLoai_Yt.Font = new Font("Arial", 8.25f);
            this.lblLoai_Yt.Location = new Point(12, 0x61);
            this.lblLoai_Yt.Name = "lblLoai_Yt";
            this.lblLoai_Yt.Size = new Size(60, 14);
            this.lblLoai_Yt.TabIndex = 4;
            this.lblLoai_Yt.Text = "Loại yếu tố";
            this.txtLoai_Yt.CharacterCasing = CharacterCasing.Upper;
            this.txtLoai_Yt.CheckTextSearched = false;
            this.txtLoai_Yt.DisabledForeColor = Color.Empty;
            this.txtLoai_Yt.Font = new Font("Arial", 8.25f);
            this.txtLoai_Yt.InputMask = "1,2,3,4";
            this.txtLoai_Yt.Location = new Point(0x7b, 0x5e);
            this.txtLoai_Yt.Name = "txtLoai_Yt";
            this.txtLoai_Yt.OldValue = null;
            this.txtLoai_Yt.Size = new Size(0x17, 20);
            this.txtLoai_Yt.TabIndex = 3;
            this.txtLoai_Yt.Text = "1";
            this.txtLoai_Yt.Value = "1";
            this.lblLoai_Yt0.AutoSize = true;
            this.lblLoai_Yt0.Font = new Font("Arial", 8.25f);
            this.lblLoai_Yt0.ForeColor = Color.Blue;
            this.lblLoai_Yt0.Location = new Point(0x98, 0x61);
            this.lblLoai_Yt0.Name = "lblLoai_Yt0";
            this.lblLoai_Yt0.Size = new Size(0xe4, 14);
            this.lblLoai_Yt0.TabIndex = 0x21;
            this.lblLoai_Yt0.Text = "1-NVLTT, 2-NCTT, 3-CP chung, 4-Chi phí kh\x00e1c";
            this.txtTk_Cp.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTk_Cp.CheckTextSearched = false;
            this.txtTk_Cp.DisabledForeColor = Color.Empty;
            this.txtTk_Cp.Font = new Font("Arial", 8.25f);
            this.txtTk_Cp.Location = new Point(0x7b, 0x74);
            this.txtTk_Cp.MaxLength = 128;
            this.txtTk_Cp.Name = "txtTk_Cp";
            this.txtTk_Cp.OldValue = null;
            this.txtTk_Cp.Size = new Size(0x181, 20);
            this.txtTk_Cp.TabIndex = 5;
            this.txtTk_Cp.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTk_Cp.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTk_Cp.Value = null;//manager.GetObject("txtTk_Cp.Value");
            this.txtTk_Yt.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTk_Yt.CheckTextSearched = false;
            this.txtTk_Yt.DisabledForeColor = Color.Empty;
            this.txtTk_Yt.Font = new Font("Arial", 8.25f);
            this.txtTk_Yt.Location = new Point(0x7b, 0x8a);
            this.txtTk_Yt.MaxLength = 128;
            this.txtTk_Yt.Name = "txtTk_Yt";
            this.txtTk_Yt.OldValue = null;
            this.txtTk_Yt.Size = new Size(0x181, 20);
            this.txtTk_Yt.TabIndex = 6;
            this.txtTk_Yt.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTk_Yt.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTk_Yt.Value = null;//manager.GetObject("txtTk_Yt.Value");
            this.lblTk_Cp.AutoSize = true;
            this.lblTk_Cp.Font = new Font("Arial", 8.25f);
            this.lblTk_Cp.Location = new Point(12, 0x77);
            this.lblTk_Cp.Name = "lblTk_Cp";
            this.lblTk_Cp.Size = new Size(0x57, 14);
            this.lblTk_Cp.TabIndex = 4;
            this.lblTk_Cp.Text = "Tài khoản chi phí";
            this.lblTk_Yt.AutoSize = true;
            this.lblTk_Yt.Font = new Font("Arial", 8.25f);
            this.lblTk_Yt.Location = new Point(12, 0x8d);
            this.lblTk_Yt.Name = "lblTk_Yt";
            this.lblTk_Yt.Size = new Size(0x56, 14);
            this.lblTk_Yt.TabIndex = 4;
            this.lblTk_Yt.Text = "Tài khoản yếu tố";
            base.AddTitleText = "Thêm mới yếu tố chi phí";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x20d, 0xc2);
            base.Controls.Add(this.lblLoai_Yt0);
            base.Controls.Add(this.txtLoai_Yt);
            base.Controls.Add(this.lblLoai_Yt);
            base.Controls.Add(this.lblTk_Yt);
            base.Controls.Add(this.lblTen_Yt_E);
            base.Controls.Add(this.lblTk_Cp);
            base.Controls.Add(this.lblTen_Yt);
            base.Controls.Add(this.lblMa_Yt);
            base.Controls.Add(this.txtTk_Yt);
            base.Controls.Add(this.txtTen_Yt_E);
            base.Controls.Add(this.txtTk_Cp);
            base.Controls.Add(this.txtTen_Yt);
            base.Controls.Add(this.txtMa_Yt);
            base.EditTitleText = "Sửa yếu tố chi phí";
            base.FirstFreeCode = "SP1";
            base.Name = "FormDmYtEditor";
            base.SecondFreeCode = "SP2";
            this.Text = "Thêm mới yếu tố chi phí";
            base.ThirdFreeCode = "SP3";
            base.Controls.SetChildIndex(base.lblPhan_Loai, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai1, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai2, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai3, 0);
            base.Controls.SetChildIndex(this.txtMa_Yt, 0);
            base.Controls.SetChildIndex(this.txtTen_Yt, 0);
            base.Controls.SetChildIndex(this.txtTk_Cp, 0);
            base.Controls.SetChildIndex(this.txtTen_Yt_E, 0);
            base.Controls.SetChildIndex(this.txtTk_Yt, 0);
            base.Controls.SetChildIndex(this.lblMa_Yt, 0);
            base.Controls.SetChildIndex(this.lblTen_Yt, 0);
            base.Controls.SetChildIndex(this.lblTk_Cp, 0);
            base.Controls.SetChildIndex(this.lblTen_Yt_E, 0);
            base.Controls.SetChildIndex(this.lblTk_Yt, 0);
            base.Controls.SetChildIndex(this.lblLoai_Yt, 0);
            base.Controls.SetChildIndex(this.txtLoai_Yt, 0);
            base.Controls.SetChildIndex(this.lblLoai_Yt0, 0);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_Yt.Text))
            {
                MessageBox.Show("Chưa nhập mã yếu tố!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_Yt.Text))
            {
                MessageBox.Show("Chưa nhập tên yếu tố!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Yt"] = this.txtMa_Yt.Value;
            localCurrentRow["Ten_Yt"] = this.txtTen_Yt.Value;
            localCurrentRow["Ten_Yt_E"] = this.txtTen_Yt_E.Value;
            localCurrentRow["Tk_Cp"] = this.txtTk_Cp.Value;
            localCurrentRow["Tk_Yt"] = this.txtTk_Yt.Value;
            localCurrentRow["Loai_Yt"] = this.txtLoai_Yt.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            localCurrentRow["Ma_Loai3"] = base.txtMa_Loai3.Value;
            DmYtDataAccess access = new DmYtDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Yt.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Yt.Value = base.LocalCurrentRow["Ma_Yt"];
            this.txtTen_Yt.Value = base.LocalCurrentRow["Ten_Yt"];
            this.txtTen_Yt_E.Value = base.LocalCurrentRow["Ten_Yt_E"];
            this.txtTk_Cp.Value = base.LocalCurrentRow["Tk_Cp"];
            this.txtTk_Yt.Value = base.LocalCurrentRow["Tk_Yt"];
            this.txtLoai_Yt.Value = base.LocalCurrentRow["Loai_Yt"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.txtMa_Loai3.Value = base.LocalCurrentRow["Ma_Loai3"];
            base.OnShow();
        }
    }
}

